Skip to content

Conversation

@venerjoel99
Copy link
Contributor

This example showcases an example of a human-in-the-loop workflow with Discord. The workflow will do the following:

  • Message the channel to start messaging the bot
  • Listen for messages sent after the last message sent by the bot
  • For each message, reply with the backwards message.
  • If the message is the word STOP, end the workflow

@restack-app
Copy link

restack-app bot commented Nov 16, 2024

No applications have been configured for previews targeting branch: main. To do so go to restack console and configure your applications for previews.

@venerjoel99
Copy link
Contributor Author

@justrdk Here is a simple human-in-the-loop example using the Discord API in the Restack workflow

@venerjoel99
Copy link
Contributor Author

@justrdk
Copy link
Contributor

justrdk commented Nov 20, 2024

@venerjoel99 isn't there a way to get events when a message is sent on the server instead of polling messages in the workflow?

@justrdk justrdk closed this Nov 20, 2024
@justrdk justrdk reopened this Nov 20, 2024


while (!endWorkflow) {
await new Promise(f => setTimeout(f, 1000));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you an use the "sleep" function from @restackio/ai/workflow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved the sleep to the scheduleWorkflow.ts file, but I can't use the sleep function in that file since it's not allowed to be used outside of a workflow execution

@venerjoel99
Copy link
Contributor Author

venerjoel99 commented Nov 22, 2024

@venerjoel99 isn't there a way to get events when a message is sent on the server instead of polling messages in the workflow?

I can make a real-time event-based workflow example. I will respond here once I add the example here

@justrdk
Copy link
Contributor

justrdk commented Nov 22, 2024

@venerjoel99 isn't there a way to get events when a message is sent on the server instead of polling messages in the workflow?

I can make a real-time event-based workflow example. I will respond here once I add the example here

perfect, to have the workflow keep on running while waiting on events you can use the "condition" functions from @restackio/ai/workflow

@venerjoel99
Copy link
Contributor Author

@justrdk I have made changes to sending events to the Restack workflow based on real-time Discord messaging events picked up by the bot

@justrdk justrdk merged commit 0af3667 into restackio:main Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants