0

Whenever a Circuit Bot is getting added to a Circuit conversation, I want to trigger an event like,

1) A Bot introducing itself. 2) Send some Circuit Forms to get some info etc.

Kamal Garg
  • 107
  • 1
  • 2
  • 9

1 Answers1

0

There are two ways to do so :

JS SDK

If you use the JS SDK to implement your bot, you can subscribe to the event

// register a webhook to listen to new items added
await fetch(`${DOMAIN}/rest/v2/webhooks`, {
  method: 'POST',
    headers: { 
      'Authorization': 'Bearer ' + token
    },
    body: `url=${encodeURI(`${URL}/webhook`)}&filter=CONVERSATION.CREATE`
});

Doing so, every time your bot is added to a conversation, you will receive an event and you can then execute the logic to post a welcome message or form

Rest API

Use the Rest API to subscribe to the same CONVERSATION.CREATE event and, same as option 1, when the bot is added to a conversation, your webhook Url will be triggered.

samo
  • 354
  • 2
  • 7