05-17-2022 05:01 AM - edited 05-17-2022 05:48 AM
Hello!
I want to send welcome message after direct with bot was opened.
I've tried spawn action, but I didn't get a welcome message.
As I understand, room isn't created after a direct was opened.
Would you mind helping me how can I implement this behaviour?
framework.on('spawn', async (bot, id, addedBy)=> { if (!addedBy) { framework.debug(`Framework created an object for an existing bot in a space called: ${bot.room.title}`); } else { bot.say('Hi there'); } });
05-17-2022 10:03 AM
A quirk of the system appears to be that the membership created event does not occur until a message is sent to the bot (or maybe some other action like viewing content?). Also, if you've been testing repeatedly with the same user/bot: 'leaving' a 1:1 space (i.e. with the bot) does not delete the space on the backend - merely hides it; as a result, if you try to 'start a new 1:1' with the bot, the old space will be resurrected, and no new membership event will occur. You may need to delete/recreate the bot on each iteration to really test this...
05-18-2022 05:27 AM
@dstaudt wrote:
A quirk of the system appears to be that the membership created event does not occur until a message is sent to the bot (or maybe some other action like viewing content?). Also, if you've been testing repeatedly with the same user/bot: 'leaving' a 1:1 space (i.e. with the bot) does not delete the space on the backend - merely hides it; as a result, if you try to 'start a new 1:1' with the bot, the old space will be resurrected, and no new membership event will occur. You may need to delete/recreate the bot on each iteration to really test this...
Same as before, direct spaces need to have a message sent, so that the functionality sees it as a created room and created membership. As for deleting the space, your findings are correct. It is not deleted, it is in fact archived in backend and therefore when a user contacts the other user again through direct space, it will revive the same space as before. The only time a direct space is actually deleted is when one or both of the users who were in the direct space are deleted/removed as webex users. All this is the designed behaviour.
05-18-2022 02:07 AM
Oh. Is there another way to understand that direct was opened?
It would be perfect if bot was introducing itself without any action from user. Regarding "leaving 1:1 space" - yeah I know about that.
05-18-2022 05:30 AM
@tatianaivanova wrote:
Oh. Is there another way to understand that direct was opened?
It would be perfect if bot was introducing itself without any action from user. Regarding "leaving 1:1 space" - yeah I know about that.
The only way to see when a direct space was opened is through the events you see already, rooms;created, memberships:created, etc. If the space was already created before, and users who were part of it still exist, then you only need to look for the messages:created event. The data object in the response will also show the roomId so this can then be used to fetch room details if you wish. You say 'It would be perfect if bot was introducing itself without any action from user' , the bot would only be able to introduce itself through a message, so having the listener for messages:created event would be enough in this case.
05-17-2022 06:13 AM
As you are using the webex-node-bot-framework
, it would be great if you could confirm if the issue is reproducible outside of this framework. For that you could use this websocket demo https://webexsamples.github.io/browser-sdk-samples/browser-socket/ and initialise it with the bot's access token.
The reason for asking above test is because our team does not directly support the webex-node-bot-framework
and it would be important to isolate if this issue is coming from the framework only. If the issue is only reproducible with the framework we would recommend getting in touch with the support channel of the framework as mentioned here https://developer.webex.com/blog/a-deeper-dive-into-the-webex-bot-framework-for-node-js
05-17-2022 08:38 AM
I checked at cosole https://webexsamples.github.io/browser-sdk-samples/browser-socket/
And I've got room created event only after clicked to "content" Tab and selected "virtual desk". (I've also got 2 membership created events)
If only I open direct with bot I don't get any action.
I've tried two times and every time I get the same result.
05-18-2022 05:24 AM - edited 05-18-2022 05:32 AM
@tatianaivanova wrote:
I checked at cosole https://webexsamples.github.io/browser-sdk-samples/browser-socket/
And I've got room created event only after clicked to "content" Tab and selected "virtual desk". (I've also got 2 membership created events)
If only I open direct with bot I don't get any action.
I've tried two times and every time I get the same result.
I'm not sure what is happening for you but when I tested this, I created a fresh new bot, then I had another user contact it through a direct space and it provided me the rooms:created and messages:created event. I didn't need to switch between tabs or anything. But please note that usually for direct spaces there needs to be some kind of action to accompany the room being created, for example sending a message or something. I think this might also be a possible reason for the perceived issue you see. But the way it's designed means that you need to send a message, along with creating the room. the rooms:created event will only get triggered when 1st message is sent.
05-18-2022 05:56 AM
Room is created if I send message, it' works fine. But I would like to have a welcome message from bot when the dialog was opened and without message from user.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide