0

I am building Slack App using Bolt SDK. Based on tutorial I have create a app.js:

const { App } = require('@slack/bolt');
const jsforce = require('jsforce');

// Initializes your app with your bot token and signing secret

const app = new App({
    token: process.env.SLACK_BOT_TOKEN,
    signingSecret: process.env.SLACK_SIGNING_SECRET,
    port: process.env.PORT || 3000
});

(async () => {
    // Start your app
    await app.start();
    console.log('⚡️ Bolt app is running!');
})();

app.shortcut('who_am_i', async ({ 
    shortcut,
    ack,
    client 
}) => {
    try {
        const connection = new jsforce.Connection({
            loginUrl: process.env.SF_LOGIN_URL
        });
        const userInfo = await connection.login(
            process.env.SF_USERNAME,
            process.env.SF_PASSWORD
            );
        // Acknowledge shortcut request
        await ack();
        // Call the views.open method using one of the built-in WebClients
        const result = await client.views.open({
            trigger_id: shortcut.trigger_id,
            view: {
                type: 'modal',
                title: {
                    type: 'plain_text',
                    text: 'My App'
                },
                close: {
                    type: 'plain_text',
                    text: 'Close'
                },
                blocks: [{
                    type: 'section',
                    text: {
                        type: 'mrkdwn',
                        text: `Slack ID, ${shortcut.user.id} SF User ID ${userInfo.id}`
                    }
                }]
            }
        });
        console.log(result);
    } catch (error) {
        console.error(error);
    }
});

Now I try to trigger a Salesforce Flow using shortcut, but cannot find any related documentation regarding this.

Is it possible to trigger a flow (named 'TestFlow') using Bolt SDK? If yes, how I can do it? Is there documentation?

App logic: Slack user will run a shortcut, will get modal where he/she will input number and after clicking "Submit" button user will trigger a flow.

I can add view for inputting the number, but I cannot find anything related to the flow triggering.

1 Answer 1

0

This answer may help you. Essentially, you can call the Flow directly via the standard REST endpoints that platform provides. The architecture of the app you've created is using jsforce to communicate with Salesforce, so you can simply make a request to the Flow endpoint once the user has provided the input required along the lines of:

var _request = {
  url: '/services/data/v54.0/actions/custom/flow/FlowName',
  method: 'post',
  body: JSON.stringify(
    {
      inputs: [
        numberInput: userInput
      ]
    }
  ),
  headers : {
          "Content-Type" : "application/json"
      }
};

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .