Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twilio receive text message agent #1418

Merged
merged 2 commits into from Apr 20, 2016

Conversation

albertsun
Copy link
Contributor

To be merged after #1415

An agent for receiving text messages from Twilio. It requires somewhat different logic from the existing webhook agent.

@cantino
Copy link
Member

cantino commented Apr 10, 2016

Cool! Do you think it would make sense to merge this into the existing Twilio Agent? I'm generally a fan of fewer agents.

@albertsun
Copy link
Contributor Author

If this were part of the existing Twilio agent it would need a mode option or something to switch between read/write. To me that's more confusing than simply having separate agents for sending to and receiving from Twilio. (Kind of the way there are different agents for different Twitter actions).

@albertsun albertsun force-pushed the feature/twilio-receive-texts branch from 2a3073b to 35779ee Compare April 11, 2016 00:40
@cantino
Copy link
Member

cantino commented Apr 11, 2016

@dsander / @knu, this is coming up a lot. Do either of you have an opinion on unified Agents vs Agent-per-action?

@dsander
Copy link
Collaborator

dsander commented Apr 11, 2016

I generally prefer a couple simple agents over one complicated one that does a lot, especially when the separation can be made clear in the agent name/description. While writing the LocalFile and CsvAgent I was unsure and went with the mode approach but regretted it relatively soon, the code and description got pretty complicated.

We could introduce a general mode concept to agents which would dynamically change the description, the from configurable fields or the default options.

@albertsun
Copy link
Contributor Author

If the goal is to have a more navigable number of agents on the New Agent screen, what about grouping agents into related modules like Agents::Twilio::SendText and Agents::Twilio::ReceiveText. They could then be grouped together on the New screen and in other places.

@albertsun albertsun force-pushed the feature/twilio-receive-texts branch from 4ee13dc to 0a12b86 Compare April 11, 2016 22:26
@cantino
Copy link
Member

cantino commented Apr 13, 2016

That seems like a good idea @albertsun. I think I'm still biased towards just having a TwilioAgent that can do a couple things (e.g., one agent per integration instead of one agent per integration behavior), but I don't feel strongly.

@albertsun albertsun force-pushed the feature/twilio-receive-texts branch from 0a12b86 to b82fb1c Compare April 13, 2016 15:23
if method(:receive_web_request).arity == 1
handled_request = receive_web_request(request)
else
handled_request = receive_web_request(params, request.method_symbol.to_s, request.format)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need request.format.to_s to match what was in the controller?

don't need securerandom

don't assume ENV['DOMAIN'] exists

update TwilioReceiveTextAgent to use new receive_web_request method signature
@albertsun albertsun force-pushed the feature/twilio-receive-texts branch from b82fb1c to 29d4691 Compare April 17, 2016 20:38
@albertsun
Copy link
Contributor Author

Now that #1415 is merged I rebased this on master so there's just one commit.

As for one agent that does many things vs many agents doing one thing each, I took a look through the @dsander 's CsvAgent and LocalFileAgent and the code around "mode" seems a little more complicated than I like. It's almost like writing two agents in one with conditionals and feels like it'll have harder to use tests and documentation than having simpler agents. Maybe if some of the mode concepts were implemented at the agent level?

Either way, wondering if we can just merge this agent, and discuss that further in a broader issue

#{post_url}
```

#{'The placeholder symbols above will be replaced by their values once the agent is saved.' unless id}
Copy link
Member

Choose a reason for hiding this comment

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

Nice :)

@cantino
Copy link
Member

cantino commented Apr 19, 2016

Agreed, I don't want to block this on the larger discussion about mode and one-vs-many agents.

@albertsun
Copy link
Contributor Author

Comment removed. Hope this is ready to merge now.

(As for mode and one vs many discussion, perhaps that is also part of the pulling agents into gems discussion — there could be a huginn-twilio gem that has multiple Agents::Twilio::FooAgent classes)

@cantino cantino merged commit eae83df into huginn:master Apr 20, 2016
@cantino
Copy link
Member

cantino commented Apr 20, 2016

Nice work!

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.

None yet

3 participants