Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Add custom api_host env variable #566

Closed
wants to merge 1 commit into from
Closed

Add custom api_host env variable #566

wants to merge 1 commit into from

Conversation

afilatov1989
Copy link

Allows users to change default "slack.com" api host to any custom host via env variable.
Can be useful for various api proxies needed by different services.

@jonchurch
Copy link
Contributor

jonchurch commented Dec 22, 2016

Can you help me understand what use case you have in mind for this?

Slackbot.js relies on the default slack API, not sure when an average user would ever want to change that. What are you building? 😄

@ghost
Copy link

ghost commented Dec 22, 2016

average user maybe no, but why not to have ability to change it when you need it? as I mentioned in previous PR my team needs it for testing

@@ -338,7 +338,8 @@ function Slackbot(configuration) {
slack_botkit.getAuthorizeURL = function(team_id, redirect_params) {

var scopes = slack_botkit.config.scopes;
var url = 'https://slack.com/oauth/authorize' + '?client_id=' +
var api_host = process.env.api_host ? process.env.api_host : 'slack.com';
Copy link

Choose a reason for hiding this comment

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

I think it could be more readable process.env.api_host || 'slack.com';

Copy link
Author

@afilatov1989 afilatov1989 Dec 22, 2016

Choose a reason for hiding this comment

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

I agree that it's more concise, but I think it's less readable, because the result is pretty unpredictable for js newbies. In many languages this statement will proceed boolean true, which will be converted to something like 1, "true", etc.

@@ -13,8 +13,9 @@ function noop() {}
* @returns {Object} A callback-based Slack API interface.
*/
module.exports = function(bot, config) {
var api_host = process.env.api_host ? process.env.api_host : 'slack.com';
Copy link

Choose a reason for hiding this comment

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

The same as I mentioned above

@afilatov1989
Copy link
Author

We are building a service for deploying bots to different platforms.

E.g. we have a Slack bot and want it to work on Skype.
So we provide a proxy api, which receives requests instead of a real Slack api, translates it to Skype format, and sends to Skype. Response is translated and transmitted the same way.

Link to the service: https://message.io/

@colestrode
Copy link
Contributor

If you are wanting to change the URL for testing, have a look at https://github.com/Skellington-Closet/slack-mock That will intercept your requests without needing to change the URL.

@afilatov1989
Copy link
Author

No it's not for testing. It will be used on production for switching bots from real slack api to the proxy, which I described before.

@peterswimm
Copy link
Contributor

@afilatov1989 It would probably be better to add message.io support as a intergration akin to how we implented twilio or facebook versus hacking slack specific .js files. This way you preserve slack functionality, and users can start with a message.io starter kit we can host in the project if that is how they want to start building their bot.

@benbrown
Copy link
Contributor

This is included in 0.5!

@benbrown benbrown closed this Feb 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants